#include<iostream>
#include<WinSock2.h>
#include<Windows.h>
#include<WS2tcpip.h>

#pragma comment(lib,"Ws2_32.lib")

using namespace std;

void server()
{
    WSADATA wsaData;
    WSAStartup(MAKEWORD(2,2),&wsaData);
    //微软独有的设置

    int socketFd = socket(AF_INET, SOCK_STREAM, 0);
    
    struct sockaddr_in serverAddress; //服务端地址
    serverAddress.sin_family = AF_INET;
    serverAddress.sin_addr.s_addr = 0x00000000;
    serverAddress.sin_port = 0x10FF;

    bind(socketFd,(struct sockaddr*)&serverAddress,sizeof(serverAddress));

    listen(socketFd,6);

    struct sockaddr_in clientAddress;//客户端地址
    socklen_t len = sizeof(clientAddress);
    int connection = accept(socketFd,(struct sockaddr*)&clientAddress,&len);

    //执行到这,说明已经建立链接了,可以读取数据了
    const int size = 100;
    char data[size];
    recv(connection,data,size,0);

    printf("%s\n",data);
}

int main(int argc,char** argv){
    sever();
    return 0;
}